package com.example.boot1;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

class MyThread implements Callable<Integer>{

    @Override
    public Integer call() throws Exception {
        System.out.println("************* come in callable");
        return 1024;
    }
}

public class CallableDemo {
    public static void main(String[] args) throws Exception{
        FutureTask<Integer> futureTask = new FutureTask<>(new MyThread());
        //因为FutureTask 实现了Runnable 接口
        Thread t1 = new Thread(futureTask,"AA");
        t1.start();//启动线程

        //线程返回值
        System.out.println("*****result=>"+futureTask.get());

    }
}
